<?php

class Control_Contents extends QUI_Control_Abstract
{
	function render()
	{
		$udi	= $this->get('udi', 'news/view');
		$limit	= $this->get('pagesize', 6);
		$cateid	= $this->get('cateid', 1);
		$order	= $this->get('order', 'id desc');
		$tpl	= $this->get('tpl','{id}');
		$date	= $this->get('date','Y-m-d H:i:s');
		$contents = Contents::find('`status`=1 and cateid = ?',$cateid)->order($order)->limitPage(1,$limit)->get();
		$return_string = '';
		foreach ($contents as $item)
		{
			$t = $tpl;
			$t = str_replace('{id}', $item->id, $t);
			$t = str_replace('{title}', $item->title, $t);
			$t = str_replace('{time}', date($date,$item->createtime) , $t);
			$t = str_replace('{url}', url($udi,array('id'=>$item->id)), $t);
			$return_string .= $t;
		}
		return $return_string;
	}
}